<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="vue.js"></script>
<script>
    const eventEmitter = new Vue()

    const clickHandler = data => {
        console.log(data);
    }

    const clickHandler2 = data => {
        console.error(data);
    }

    eventEmitter.$on('click', clickHandler)

    eventEmitter.$on('click', clickHandler2)

    eventEmitter.$once('clickOnce', data => {
        console.log(data);
    })

    setTimeout(() => {
        // eventEmitter.$off()

        eventEmitter.$emit('click', 'hello world!')
        eventEmitter.$emit('click', 'hello world! 2')

        // eventEmitter.$off('click')
        eventEmitter.$off('click', clickHandler2)

        eventEmitter.$emit('click', 'hello world! 3')

        eventEmitter.$emit('clickOnce', 'hello clickOnce')
        eventEmitter.$emit('clickOnce', 'hello clickOnce 2')
    }, 1000)
</script>
</body>
</html>
